package br.ita.trucocearense.cliente.core.padraoobserver;

import java.rmi.RemoteException;
import java.util.ArrayList;

import br.ita.trucocearense.cliente.core.interfaces.padraobserver.Observer;
import br.ita.trucocearense.cliente.core.interfaces.padraobserver.Subject;

public class SubjectImpl implements Subject {

	private ArrayList<Observer> obs = new ArrayList<Observer>();
	
	@Override
	public void notifyObservers(String reference) throws RemoteException {
		for(int i = 0; i < obs.size(); i++) {
			obs.get(i).update(reference);
		}
	}

	@Override
	public void registerObserver(Observer o) {
		this.obs.add(o);
	}

	@Override
	public void removeObserver(Observer o) {
		this.obs.remove(o);
	}

}
